package com.ymatou.iapi.receiverkmq.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;
/**
*发布消息接口Call
*FreeMaker Template自动生成代码
*/
public class PublishCall extends YmatouBaseCall{
	private static String opurl ="Message/Kafka/Publish";
	
	public PublishCall() {
		super(EnvSetup.getSystemUrl("mqpublishkafka"),opurl,"POST","JSON");
		//	super(EnvSetup.getSystemUrl("kmqpublish"),opurl,"POST","JSON");

		
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getCode() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("code");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}

	/**
	 * 获取Msg
	 * 
	 * @return
	 */
	public String getMsg() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).getString("message");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Result
	 * 
	 * @return
	 */
	public JSONObject getResult() {
		JSONObject Data = null;
		try {
			Data = new JSONObject(getReturnData()).getJSONObject("Result");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Data;
	}
}